<?php
namespace app\api\controller;


use app\extra\ApiToken;
use app\extra\DBCont;
use EasyWeChat\Factory;
use think\Db;

/**
 * @title 是否关注微信公众号
 * @description 获取是否关注微信公众号
 * @group 微信报名分销
 */
class Follow extends Base
{
    protected $_order = 'id desc';
    /**
     * @title 获取是否关注微信公众号
     * @description 接口说明
     * @author hardy
     * @url /api/Follow
     * @method GET
     * @return 是否关注，status=false未关注，status=true已关注
     */
    public function gets()
    {

        $config = [
            'app_id' => ENV("WX_APP_ID"),
            'secret' => ENV("WX_APP_SECRET")
        ];
        $app = Factory::officialAccount($config);
        $openid = $this->getUserAttr('openid');
        $user = $app->user->get($openid);
        if ($user['subscribe']){
            $this->responseSuccess('已关注');
        } else {
            $this->responseFail('未关注');
        }

    }
}